package common;

import java.io.File;
import java.util.Properties;

/**
 * A class abstraction of the configuration file (used for testing)
 * 
 * @author Gal Lalouche
 */
public class Configuration {
	private static Configuration	instance;
	private Properties				props;
	private String					realPath;
	
	private Configuration() {
		props = new Properties();
		props.setProperty("password", "1234");
		props.setProperty("url", "jdbc:mysql://localhost:3306/");
		props.setProperty("dbName", "servlets");
		props.setProperty("username", "root");
		props.setProperty("driver", "com.mysql.jdbc.Driver");
		this.realPath = new File(".").getAbsolutePath();
	}
	
	/**
	 * @return The instance
	 */
	public static Configuration getInstance() {
		if (instance == null) {
			instance = new Configuration();
		}
		return instance;
	}
	
	/**
	 * Sets the configuration properties
	 * 
	 * @param props The properties to set
	 */
	public void setProps(Properties props) {
		if (props == null) {
			throw new IllegalArgumentException("props is null");
		}
		this.props = props;
	}
	
	/**
	 * @return The configuration properties
	 */
	public Properties getProps() {
		return props;
	}
	
	/**
	 * @return the realPath
	 */
	public String getRealPath() {
		return realPath;
	}
	
	/**
	 * @param realPath the realPath to set
	 */
	public void setRealPath(String realPath) {
		this.realPath = realPath;
	}
}
